import { Freer, SandBox, SandBoxType } from '../../interfaces';
import patchDynamicAppend from './dynamicAppend';
import patchHistoryListener from './historyListener';
import patchInterval from './interval';
import patchWindowListener from './windowListener';
import * as css from './css';
export function patchAtMounting(appName, elementGetter, sandbox, singular, scopedCSS, excludeAssetFilter) {
  const basePatchers = [
    // 定时器 patch
    () => patchInterval(sandbox.proxy), 
    // 事件监听 patch
    () => patchWindowListener(sandbox.proxy),
    // fix umi bug
    () => patchHistoryListener(),
    // 初始化阶段时的那个 patch
    // TODO
    () => patchDynamicAppend(appName, elementGetter, sandbox.proxy, true, singular, scopedCSS, excludeAssetFilter),
  ];
  const patchersInSandbox = {
    [SandBoxType.LegacyProxy]: [...basePatchers],
    [SandBoxType.Proxy]: [...basePatchers],
    [SandBoxType.Snapshot]: basePatchers
  };
  return patchersInSandbox[sandbox.type]?.map(patch => patch());
}
export function patchAtBootstrapping(appName, elementGetter, sandbox, singular, scopedCSS, excludeAssetFilter) {
  const basePatchers = [() => patchDynamicAppend(appName, elementGetter, sandbox.proxy, false, singular, scopedCSS, excludeAssetFilter)];
  const patchersInSandbox = {
    [SandBoxType.LegacyProxy]: basePatchers,
    [SandBoxType.Proxy]: basePatchers,
    [SandBoxType.Snapshot]: basePatchers
  };
  return patchersInSandbox[sandbox.type]?.map(patch => patch());
}
export { css };